package com.xiaozhou.file;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */
public class ExcelUtils {

    public static List<ExcelDTO> getExcelList(){
        ArrayList<ExcelDTO> excelDTOS = new ArrayList<>();
        EasyExcel.read("C:\\Users\\Administrator\\Desktop\\非重疾导入版.xlsx", ExcelDTO.class, new ReadListener() {
            @Override
            public void invoke(Object data, AnalysisContext context) {
                excelDTOS.add((ExcelDTO) data);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                System.out.println("完成");
            }
        }).doReadAll();
        return excelDTOS;
    }

    public static List<ExcelDTO> getExcelList1(){
        ArrayList<ExcelDTO> excelDTOS = new ArrayList<>();
        EasyExcel.read("C:\\Users\\Administrator\\Desktop\\重疾导入.xlsx", ExcelDTO.class, new ReadListener() {
            @Override
            public void invoke(Object data, AnalysisContext context) {
                excelDTOS.add((ExcelDTO) data);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext context) {
                System.out.println("完成");
            }
        }).doReadAll();
        return excelDTOS;
    }

    public static void main(String[] args) {
        List<ExcelDTO> excelList = getExcelList();
        System.out.println(excelList);
    }
}
